<?php

declare(strict_types=1);
/**
 * This file is part of Hyperf.
 *
 * @link     https://www.hyperf.io
 * @document https://hyperf.wiki
 * @contact  group@hyperf.io
 * @license  https://github.com/hyperf/hyperf/blob/master/LICENSE
 */

namespace core\utils;

use Carbon\Carbon;

class Time
{
    const DATE_TIME = "Y-m-d H:i:s";

    static function now()
    {
        return date("Y-m-d H:i:s");
    }

    static function nowS()
    {
        return time();
    }

    static function getDayStart($s)
    {
        return Carbon::parse($s)->startOfDay()->getTimestamp();
    }

    static function getDayEnd($s)
    {
        return Carbon::parse($s)->endOfDay()->getTimestamp();
    }

    static function getMonthStart($s)
    {
        return Carbon::parse($s)->startOfMonth()->getTimestamp();
    }

    static function getMonthEnd($s)
    {
        return Carbon::parse($s)->endOfMonth()->getTimestamp();
    }

    static function getMonthStartDateTime($s)
    {
        return Carbon::parse($s)->startOfMonth()->toDateTimeString();
    }

    static function getMonthEndDateTime($s)
    {
        return Carbon::parse($s)->endOfMonth()->toDateTimeString();
    }

    static function getDayStartDateTime($s)
    {
        return Carbon::parse($s)->startOfDay()->format(self::DATE_TIME);
    }

    static function getDayEndDateTime($s)
    {
        return Carbon::parse($s)->endOfDay()->format(self::DATE_TIME);
    }
}
